package model

import (
	"database/sql"
	"time"

	"github.com/guregu/null"
	"github.com/satori/go.uuid"
)

var (
	_ = time.Second
	_ = sql.LevelDefault
	_ = null.Bool{}
	_ = uuid.UUID{}
)

/*
DB Table Details
-------------------------------------


CREATE TABLE `custom_process_base_machine_rel` (
  `base_id` bigint(20) unsigned zerofill NOT NULL,
  `machine_id` bigint(20) unsigned zerofill NOT NULL,
  PRIMARY KEY (`base_id`,`machine_id`),
  KEY `fk_custom_process_base_has_machine_machine1` (`machine_id`),
  CONSTRAINT `fk_custom_process_base_has_machine_custom_process_base1` FOREIGN KEY (`base_id`) REFERENCES `custom_process_base` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_custom_process_base_has_machine_machine1` FOREIGN KEY (`machine_id`) REFERENCES `machine` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

JSON Sample
-------------------------------------
{    "base_id": 73,    "machine_id": 73}


Comments
-------------------------------------
[ 0] column is set for unsigned
[ 1] column is set for unsigned



*/

// CustomProcessBaseMachineRel struct is a row record of the custom_process_base_machine_rel table in the custom_process database
type CustomProcessBaseMachineRel struct {
	//[ 0] base_id                                        ubigint              null: false  primary: true   isArray: false  auto: false  col: ubigint         len: -1      default: []
	BaseID uint64 `gorm:"primary_key;column:base_id;type:ubigint;" json:"base_id"`
	//[ 1] machine_id                                     ubigint              null: false  primary: true   isArray: false  auto: false  col: ubigint         len: -1      default: []
	MachineID uint64 `gorm:"primary_key;column:machine_id;type:ubigint;" json:"machine_id"`
}

var custom_process_base_machine_relTableInfo = &TableInfo{
	Name: "custom_process_base_machine_rel",
	Columns: []*ColumnInfo{

		{
			Index:              0,
			Name:               "base_id",
			Comment:            ``,
			Notes:              `column is set for unsigned`,
			Nullable:           false,
			DatabaseTypeName:   "ubigint",
			DatabaseTypePretty: "ubigint",
			IsPrimaryKey:       true,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "ubigint",
			ColumnLength:       -1,
			GoFieldName:        "BaseID",
			GoFieldType:        "uint64",
			JSONFieldName:      "base_id",
			ProtobufFieldName:  "base_id",
			ProtobufType:       "uint64",
			ProtobufPos:        1,
		},

		{
			Index:              1,
			Name:               "machine_id",
			Comment:            ``,
			Notes:              `column is set for unsigned`,
			Nullable:           false,
			DatabaseTypeName:   "ubigint",
			DatabaseTypePretty: "ubigint",
			IsPrimaryKey:       true,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "ubigint",
			ColumnLength:       -1,
			GoFieldName:        "MachineID",
			GoFieldType:        "uint64",
			JSONFieldName:      "machine_id",
			ProtobufFieldName:  "machine_id",
			ProtobufType:       "uint64",
			ProtobufPos:        2,
		},
	},
}

// TableName sets the insert table name for this struct type
func (c *CustomProcessBaseMachineRel) TableName() string {
	return "custom_process_base_machine_rel"
}

// BeforeSave invoked before saving, return an error if field is not populated.
func (c *CustomProcessBaseMachineRel) BeforeSave() error {
	return nil
}

// Prepare invoked before saving, can be used to populate fields etc.
func (c *CustomProcessBaseMachineRel) Prepare() {
}

// Validate invoked before performing action, return an error if field is not populated.
func (c *CustomProcessBaseMachineRel) Validate(action Action) error {
	return nil
}

// TableInfo return table meta data
func (c *CustomProcessBaseMachineRel) TableInfo() *TableInfo {
	return custom_process_base_machine_relTableInfo
}
